{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "import pandas as pd\n",
    "from math import comb\n",
    "import pickle\n",
    "import time"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Parameters**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "v=30\n",
    "lam=.125\n",
    "c=1\n",
    "T=10\n",
    "N=4\n",
    "scale=1000"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "dO=[[draw_outcomes(y,z,FS) for z in range(N+1)] for y in range(N+1)]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Import Last Period**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 160,
   "metadata": {},
   "outputs": [],
   "source": [
    "period=1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 161,
   "metadata": {},
   "outputs": [],
   "source": [
    "payoffsF=pickle.load(open(\"Alternative_Follower_Payoffs_Period_%s_%s_%s_%s.pkl\"%(period+1,N,v,c),\"rb\"))\n",
    "payoffsL=pickle.load(open(\"Alternative_Leader_Payoffs_Period_%s_%s_%s_%s.pkl\"%(period+1,N,v,c),\"rb\"))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Intermediate (0 Case)**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 162,
   "metadata": {},
   "outputs": [],
   "source": [
    "com=[[comb(y,z) for z in range(y+1)] for y in range(N+1)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 163,
   "metadata": {},
   "outputs": [],
   "source": [
    "def f_enterF(pf,y,N):\n",
    "    return (comb(N-2,y)*((pf**y)*(1-pf)**(N-2-y)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 164,
   "metadata": {},
   "outputs": [],
   "source": [
    "def f_enterL(pf,y,N):\n",
    "    return (comb(N-1,y)*((pf**y)*(1-pf)**(N-1-y)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 165,
   "metadata": {},
   "outputs": [],
   "source": [
    "def pay(payoffs,x):\n",
    "#     print(int(round((scale)*(1-np.exp(-.125*x)))))\n",
    "    return payoffs[x]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 166,
   "metadata": {},
   "outputs": [],
   "source": [
    "def dFx(dexp,x):\n",
    "    return dexp*(((x-FS)/(1-FS))**(dexp-1))*((1)/(1-FS))*.001"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 167,
   "metadata": {},
   "outputs": [],
   "source": [
    "def integral0(payoffs,dexp):\n",
    "    return sum([pay(payoffs,i)*dFx(dexp,i*.001) for i in range(0,1001)])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 168,
   "metadata": {},
   "outputs": [],
   "source": [
    "def intermediate_period_0(payoffsL,payoffsF,initial):\n",
    "    \n",
    "    p=initial[0]\n",
    "    old=5\n",
    "    \n",
    "    epsilon=.01\n",
    "    \n",
    "    j=0\n",
    "    \n",
    "\n",
    "        \n",
    "    while ((abs(p-old))>1e-6):\n",
    "        \n",
    "\n",
    "        \n",
    "        vDraw1=sum([f_enterL(p,y,N)*((1/(y+1))*integralsL[y]) for y in range(N)])\n",
    "        vDraw2=sum([f_enterL(p,y,N)*((y)/(y+1))*integralsF[y] for y in range(1,N)])\n",
    "        \n",
    "        vDraw=vDraw1+vDraw2-c\n",
    "        \n",
    "        vNoDraw=payoffsL[0]*((1-p)**(N-1)) + sum([f_enterL(p,y,N)*integralsF[y-1] for y in range(1,N)])\n",
    "        \n",
    "        old=p\n",
    "\n",
    "        #Gets too big, have to adjust for this\n",
    "        pnew=(np.exp(mu*(vDraw-max(vDraw,vNoDraw))))/(np.exp(mu*(vDraw-max(vDraw,vNoDraw)))+np.exp(mu*(vNoDraw-max(vDraw,vNoDraw))))\n",
    "    \n",
    "        p=(1-epsilon)*old+epsilon*pnew\n",
    "    \n",
    "#         print(p,vDraw,vNoDraw)\n",
    "    \n",
    "    payoff=p*vDraw + (1-p)*vNoDraw\n",
    "#     print(p,vDraw,vNoDraw)\n",
    "    return p,payoff        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 169,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.0 0.9999015421795406 0.9999015421795406\n"
     ]
    }
   ],
   "source": [
    "epsilonMu=1\n",
    "leader_probs=[]\n",
    "follower_probs=[]\n",
    "leader_payoffs=[]\n",
    "follower_payoffs=[]\n",
    "\n",
    "FS=0\n",
    "\n",
    "prob=.5\n",
    "scale=1000\n",
    "\n",
    "mu=10000\n",
    "\n",
    "integralsL=[integral0(payoffsL,y+1) for y in range(N)]\n",
    "integralsF=[integral0(payoffsF,y) for y in range(1,N+1)]\n",
    "\n",
    "[prob,payoff]=intermediate_period_0(payoffsL,payoffsF,[prob])\n",
    "#         print(mu)\n",
    "leader_probs.append(prob)\n",
    "follower_probs.append(prob)\n",
    "leader_payoffs.append(payoff)\n",
    "follower_payoffs.append(payoff)\n",
    "print(.0005*FS,prob,prob)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Intermediate (>0 Case)**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 170,
   "metadata": {},
   "outputs": [],
   "source": [
    "def inverse_CDF(FS):\n",
    "    return -np.log(1-FS)/.125"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 171,
   "metadata": {},
   "outputs": [],
   "source": [
    "def draw_outcomes(exp1,exp2,FS):\n",
    "    return ((1-FS)**exp1)*(FS**exp2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 172,
   "metadata": {},
   "outputs": [],
   "source": [
    "def integral(payoffs,dexp,FS):\n",
    "    \n",
    "    if dexp==0:\n",
    "        return 0\n",
    "    else:\n",
    "        return sum([pay(payoffs,i)*dFx(dexp,i*.001) for i in range(int(round(FS*scale)),1001)])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 173,
   "metadata": {},
   "outputs": [],
   "source": [
    "def intermediate_period(FS,payoffsL,payoffsF,initial):\n",
    "    \n",
    "    \n",
    "    pl=initial[0]\n",
    "    pf=initial[1]\n",
    "\n",
    "    oldl=5\n",
    "    oldf=5\n",
    "    \n",
    "    epsilon=.01\n",
    "    \n",
    "    #Follower\n",
    "    j=0\n",
    "    \n",
    "\n",
    "    iteration=0\n",
    "    epsilon=1\n",
    "    while ((abs(pl-oldl)+abs(pf-oldf))>1e-6)&(iteration<6):\n",
    "    \n",
    "\n",
    "    \n",
    "        vFollowerDraw1=payoffsF[round(FS*scale)]*((1-pl)*FS+pl*(FS**2))*sum([f_enterF(pf,y,N)*(FS**y) for y in range(N-1)])\n",
    "        vFollowerDraw2=(1-pl)*sum([f_enterF(pf,y,N)*sum([com[y][z]*integralsF[z]*draw_outcomes(z,y+1-z,FS) for z in range(1,y+1)]) for y in range(1,N-1)])\n",
    "        vFollowerDraw3=(1-pl)*sum([f_enterF(pf,y,N)*sum([(z/(z+1))*com[y][z]*integralsF[z+1]*draw_outcomes(z+1,y-z,FS) for z in range(1,y+1)]) for y in range(1,N-1)])\n",
    "        vFollowerDraw4=pl*sum([f_enterF(pf,y,N)*sum([com[y][z]*integralsF[z]*draw_outcomes(z,y+2-z,FS) for z in range(1,y+1)]) for y in range(1,N-1)])\n",
    "        vFollowerDraw5=pl*sum([f_enterF(pf,y,N)*sum([com[y][z]*integralsF[z+1]*draw_outcomes(z+1,y+1-z,FS) for z in range(y+1)]) for y in range(N-1)])\n",
    "        vFollowerDraw6=pl*sum([f_enterF(pf,y,N)*sum([(z/(z+1))*com[y][z]*integralsF[z+1]*draw_outcomes(z+1,y+1-z,FS) for z in range(1,y+1)]) for y in range(1,N-1)])\n",
    "        vFollowerDraw7=pl*sum([f_enterF(pf,y,N)*sum([((z+1)/(z+2))*com[y][z]*integralsF[z+2]*draw_outcomes(z+2,y-z,FS) for z in range(y+1)]) for y in range(N-1)])\n",
    "        vFollowerDraw8=(1-pl)*sum([f_enterF(pf,y,N)*sum([(1/(z+1))*com[y][z]*integralsL[z+1]*draw_outcomes(z+1,y-z,FS) for z in range(y+1)]) for y in range(N-1)])       \n",
    "        vFollowerDraw9=pl*sum([f_enterF(pf,y,N)*sum([(1/(z+1))*com[y][z]*integralsL[z+1]*draw_outcomes(z+1,y+1-z,FS) for z in range(y+1)]) for y in range(N-1)])\n",
    "        vFollowerDraw10=pl*sum([f_enterF(pf,y,N)*sum([(1/(z+2))*com[y][z]*integralsL[z+2]*draw_outcomes(z+2,y-z,FS) for z in range(y+1)]) for y in range(N-1)])\n",
    "\n",
    "        vFollowerDraw=vFollowerDraw1+vFollowerDraw2+vFollowerDraw3+vFollowerDraw4+vFollowerDraw5\n",
    "        vFollowerDraw=vFollowerDraw + vFollowerDraw6+vFollowerDraw7+vFollowerDraw8+vFollowerDraw9+vFollowerDraw10\n",
    "        vFollowerDraw=vFollowerDraw-c\n",
    "\n",
    "        vFollowerNoDraw1=payoffsF[round(FS*(scale))]*((1-pl)+pl*FS)*sum([f_enterF(pf,y,N)*(FS**y) for y in range(N-1)])\n",
    "        vFollowerNoDraw2=(1-pl)*sum([f_enterF(pf,y,N)*sum([com[y][z]*integralsF[z]*draw_outcomes(z,y-z,FS) for z in range(1,y+1)]) for y in range(1,N-1)])\n",
    "        vFollowerNoDraw3=(pl)*sum([f_enterF(pf,y,N)*sum([com[y][z]*integralsF[z]*draw_outcomes(z,y+1-z,FS) for z in range(1,y+1)]) for y in range(1,N-1)])\n",
    "        vFollowerNoDraw4=pl*sum([f_enterF(pf,y,N)*sum([com[y][z]*integralsF[z+1]*draw_outcomes(z+1,y-z,FS) for z in range(y+1)]) for y in range(N-1)])\n",
    "\n",
    "        vFollowerNoDraw=vFollowerNoDraw1+vFollowerNoDraw2+vFollowerNoDraw3+vFollowerNoDraw4\n",
    "\n",
    "        vLeaderDraw1=payoffsL[round(FS*(scale))]*sum([f_enterL(pf,y,N)*(FS**(y+1)) for y in range(N)])\n",
    "        vLeaderDraw2=sum([f_enterL(pf,y,N)*sum([com[y][z]*integralsF[z]*draw_outcomes(z,y+1-z,FS) for z in range(1,y+1)]) for y in range(1,N)])\n",
    "        vLeaderDraw3=sum([f_enterL(pf,y,N)*sum([(z/(z+1))*com[y][z]*integralsF[z+1]*draw_outcomes(z+1,y-z,FS) for z in range(1,y+1)]) for y in range(1,N)])\n",
    "        vLeaderDraw4=sum([f_enterL(pf,y,N)*sum([(1/(z+1))*com[y][z]*integralsL[z+1]*draw_outcomes(z+1,y-z,FS) for z in range(y+1)]) for y in range(N)])\n",
    "\n",
    "        vLeaderDraw=vLeaderDraw1+vLeaderDraw2+vLeaderDraw3+vLeaderDraw4-c\n",
    "\n",
    "        vLeaderNoDraw1=payoffsL[round(FS*(scale))]*sum([f_enterL(pf,y,N)*(FS**y) for y in range(N)])\n",
    "        vLeaderNoDraw2=sum([f_enterL(pf,y,N)*sum([com[y][z]*integralsF[z]*draw_outcomes(z,y-z,FS) for z in range(1,y+1)]) for y in range(1,N)])\n",
    "        vLeaderNoDraw=vLeaderNoDraw1+vLeaderNoDraw2\n",
    "\n",
    "        oldl=pl\n",
    "        oldf=pf\n",
    "        \n",
    "        pfU=(np.exp(mu*(vFollowerDraw-max(vFollowerDraw,vFollowerNoDraw))))/(np.exp(mu*(vFollowerDraw-max(vFollowerDraw,vFollowerNoDraw)))+np.exp(mu*(vFollowerNoDraw-max(vFollowerDraw,vFollowerNoDraw))))  \n",
    "        plU=(np.exp(mu*(vLeaderDraw-max(vLeaderDraw,vLeaderNoDraw))))/(np.exp(mu*(vLeaderDraw-max(vLeaderDraw,vLeaderNoDraw)))+np.exp(mu*(vLeaderNoDraw-max(vLeaderDraw,vLeaderNoDraw))))\n",
    "\n",
    "        pl=(1-epsilon)*oldl + epsilon*plU\n",
    "        pf=(1-epsilon)*oldf + epsilon*pfU\n",
    "        iteration=iteration+1\n",
    "        \n",
    "    epsilon=.01\n",
    "    \n",
    "    while ((abs(pl-oldl)+abs(pf-oldf))>1e-6):\n",
    "    \n",
    "\n",
    "    \n",
    "        vFollowerDraw1=payoffsF[round(FS*scale)]*((1-pl)*FS+pl*(FS**2))*sum([f_enterF(pf,y,N)*(FS**y) for y in range(N-1)])\n",
    "        vFollowerDraw2=(1-pl)*sum([f_enterF(pf,y,N)*sum([com[y][z]*integralsF[z]*draw_outcomes(z,y+1-z,FS) for z in range(1,y+1)]) for y in range(1,N-1)])\n",
    "        vFollowerDraw3=(1-pl)*sum([f_enterF(pf,y,N)*sum([(z/(z+1))*com[y][z]*integralsF[z+1]*draw_outcomes(z+1,y-z,FS) for z in range(1,y+1)]) for y in range(1,N-1)])\n",
    "        vFollowerDraw4=pl*sum([f_enterF(pf,y,N)*sum([com[y][z]*integralsF[z]*draw_outcomes(z,y+2-z,FS) for z in range(1,y+1)]) for y in range(1,N-1)])\n",
    "        vFollowerDraw5=pl*sum([f_enterF(pf,y,N)*sum([com[y][z]*integralsF[z+1]*draw_outcomes(z+1,y+1-z,FS) for z in range(y+1)]) for y in range(N-1)])\n",
    "        vFollowerDraw6=pl*sum([f_enterF(pf,y,N)*sum([(z/(z+1))*com[y][z]*integralsF[z+1]*draw_outcomes(z+1,y+1-z,FS) for z in range(1,y+1)]) for y in range(N-1)])\n",
    "        vFollowerDraw7=pl*sum([f_enterF(pf,y,N)*sum([((z+1)/(z+2))*com[y][z]*integralsF[z+2]*draw_outcomes(z+2,y-z,FS) for z in range(y+1)]) for y in range(N-1)])\n",
    "        vFollowerDraw8=(1-pl)*sum([f_enterF(pf,y,N)*sum([(1/(z+1))*com[y][z]*integralsL[z+1]*draw_outcomes(z+1,y-z,FS) for z in range(y+1)]) for y in range(N-1)])\n",
    "        vFollowerDraw9=pl*sum([f_enterF(pf,y,N)*sum([(1/(z+1))*com[y][z]*integralsL[z+1]*draw_outcomes(z+1,y+1-z,FS) for z in range(y+1)]) for y in range(N-1)])\n",
    "        vFollowerDraw10=pl*sum([f_enterF(pf,y,N)*sum([(1/(z+2))*com[y][z]*integralsL[z+2]*draw_outcomes(z+2,y-z,FS) for z in range(y+1)]) for y in range(N-1)])\n",
    "\n",
    "        vFollowerDraw=vFollowerDraw1+vFollowerDraw2+vFollowerDraw3+vFollowerDraw4+vFollowerDraw5\n",
    "        vFollowerDraw=vFollowerDraw + vFollowerDraw6+vFollowerDraw7+vFollowerDraw8+vFollowerDraw9+vFollowerDraw10\n",
    "        vFollowerDraw=vFollowerDraw-c\n",
    "\n",
    "        vFollowerNoDraw1=payoffsF[round(FS*(scale))]*((1-pl)+pl*FS)*sum([f_enterF(pf,y,N)*(FS**y) for y in range(N-1)])\n",
    "        vFollowerNoDraw2=(1-pl)*sum([f_enterF(pf,y,N)*sum([com[y][z]*integralsF[z]*draw_outcomes(z,y-z,FS) for z in range(1,y+1)]) for y in range(1,N-1)])\n",
    "        vFollowerNoDraw3=(pl)*sum([f_enterF(pf,y,N)*sum([com[y][z]*integralsF[z]*draw_outcomes(z,y+1-z,FS) for z in range(1,y+1)]) for y in range(1,N-1)])\n",
    "        vFollowerNoDraw4=pl*sum([f_enterF(pf,y,N)*sum([com[y][z]*integralsF[z+1]*draw_outcomes(z+1,y-z,FS) for z in range(y+1)]) for y in range(N-1)])\n",
    "\n",
    "        vFollowerNoDraw=vFollowerNoDraw1+vFollowerNoDraw2+vFollowerNoDraw3+vFollowerNoDraw4\n",
    "\n",
    "        vLeaderDraw1=payoffsL[round(FS*(scale))]*sum([f_enterL(pf,y,N)*(FS**(y+1)) for y in range(N)])\n",
    "        vLeaderDraw2=sum([f_enterL(pf,y,N)*sum([com[y][z]*integralsF[z]*draw_outcomes(z,y+1-z,FS) for z in range(1,y+1)]) for y in range(1,N)])\n",
    "        vLeaderDraw3=sum([f_enterL(pf,y,N)*sum([(z/(z+1))*com[y][z]*integralsF[z+1]*draw_outcomes(z+1,y-z,FS) for z in range(1,y+1)]) for y in range(1,N)])\n",
    "        vLeaderDraw4=sum([f_enterL(pf,y,N)*sum([(1/(z+1))*com[y][z]*integralsL[z+1]*draw_outcomes(z+1,y-z,FS) for z in range(y+1)]) for y in range(N)])\n",
    "\n",
    "        vLeaderDraw=vLeaderDraw1+vLeaderDraw2+vLeaderDraw3+vLeaderDraw4-c\n",
    "\n",
    "        vLeaderNoDraw1=payoffsL[round(FS*(scale))]*sum([f_enterL(pf,y,N)*(FS**y) for y in range(N)])\n",
    "        vLeaderNoDraw2=sum([f_enterL(pf,y,N)*sum([com[y][z]*integralsF[z]*draw_outcomes(z,y-z,FS) for z in range(1,y+1)]) for y in range(1,N)])\n",
    "        vLeaderNoDraw=vLeaderNoDraw1+vLeaderNoDraw2\n",
    "\n",
    "        oldl=pl\n",
    "        oldf=pf\n",
    "        \n",
    "        pfU=(np.exp(mu*(vFollowerDraw-max(vFollowerDraw,vFollowerNoDraw))))/(np.exp(mu*(vFollowerDraw-max(vFollowerDraw,vFollowerNoDraw)))+np.exp(mu*(vFollowerNoDraw-max(vFollowerDraw,vFollowerNoDraw))))  \n",
    "        plU=(np.exp(mu*(vLeaderDraw-max(vLeaderDraw,vLeaderNoDraw))))/(np.exp(mu*(vLeaderDraw-max(vLeaderDraw,vLeaderNoDraw)))+np.exp(mu*(vLeaderNoDraw-max(vLeaderDraw,vLeaderNoDraw))))\n",
    "\n",
    "        pl=(1-epsilon)*oldl + epsilon*plU\n",
    "        pf=(1-epsilon)*oldf + epsilon*pfU\n",
    "        iteration=iteration+1    \n",
    "        \n",
    "#         print(pl,pf,(abs(pl-oldl)+abs(pf-oldf)))\n",
    "        \n",
    "    payoffF=pf*vFollowerDraw + (1-pf)*vFollowerNoDraw\n",
    "    payoffL=pl*vLeaderDraw + (1-pl)*vLeaderNoDraw\n",
    "    \n",
    "    return pl,pf,payoffL,payoffF"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 174,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.001 1.0 1.0\n",
      "0.002 1.0 1.0\n",
      "0.003 1.0 1.0\n",
      "0.004 1.0 1.0\n",
      "0.005 1.0 1.0\n",
      "0.006 1.0 1.0\n",
      "0.007 1.0 1.0\n",
      "0.008 1.0 1.0\n",
      "0.009 1.0 1.0\n",
      "0.01 1.0 1.0\n",
      "0.011 1.0 1.0\n",
      "0.012 1.0 1.0\n",
      "0.013 1.0 1.0\n",
      "0.014 1.0 1.0\n",
      "0.015 1.0 1.0\n",
      "0.016 1.0 1.0\n",
      "0.017 1.0 1.0\n",
      "0.018 1.0 1.0\n",
      "0.019 1.0 1.0\n",
      "0.02 1.0 1.0\n",
      "0.021 1.0 1.0\n",
      "0.022 1.0 1.0\n",
      "0.023 1.0 1.0\n",
      "0.024 1.0 1.0\n",
      "0.025 1.0 1.0\n",
      "0.026 1.0 1.0\n",
      "0.027 1.0 1.0\n",
      "0.028 1.0 1.0\n",
      "0.029 1.0 1.0\n",
      "0.03 1.0 1.0\n",
      "0.031 1.0 1.0\n",
      "0.032 1.0 1.0\n",
      "0.033 1.0 1.0\n",
      "0.034 1.0 1.0\n",
      "0.035 1.0 1.0\n",
      "0.036 1.0 1.0\n",
      "0.037 1.0 1.0\n",
      "0.038 1.0 1.0\n",
      "0.039 1.0 1.0\n",
      "0.04 1.0 1.0\n",
      "0.041 1.0 1.0\n",
      "0.042 1.0 1.0\n",
      "0.043 1.0 1.0\n",
      "0.044 1.0 1.0\n",
      "0.045 1.0 1.0\n",
      "0.046 1.0 1.0\n",
      "0.047 1.0 1.0\n",
      "0.048 1.0 1.0\n",
      "0.049 1.0 1.0\n",
      "0.05 1.0 1.0\n",
      "0.051 1.0 1.0\n",
      "0.052 1.0 1.0\n",
      "0.053 1.0 1.0\n",
      "0.054 1.0 1.0\n",
      "0.055 1.0 1.0\n",
      "0.056 1.0 1.0\n",
      "0.057 1.0 1.0\n",
      "0.058 1.0 1.0\n",
      "0.059 1.0 1.0\n",
      "0.06 1.0 1.0\n",
      "0.061 1.0 1.0\n",
      "0.062 1.0 1.0\n",
      "0.063 1.0 1.0\n",
      "0.064 1.0 1.0\n",
      "0.065 1.0 1.0\n",
      "0.066 1.0 1.0\n",
      "0.067 1.0 1.0\n",
      "0.068 1.0 1.0\n",
      "0.069 1.0 1.0\n",
      "0.07 1.0 1.0\n",
      "0.071 1.0 1.0\n",
      "0.072 1.0 1.0\n",
      "0.073 1.0 1.0\n",
      "0.074 1.0 1.0\n",
      "0.075 1.0 1.0\n",
      "0.076 1.0 1.0\n",
      "0.077 1.0 1.0\n",
      "0.078 1.0 1.0\n",
      "0.079 1.0 1.0\n",
      "0.08 1.0 1.0\n",
      "0.081 1.0 1.0\n",
      "0.082 1.0 1.0\n",
      "0.083 1.0 1.0\n",
      "0.084 1.0 1.0\n",
      "0.085 1.0 1.0\n",
      "0.086 1.0 1.0\n",
      "0.087 1.0 1.0\n",
      "0.088 1.0 1.0\n",
      "0.089 1.0 1.0\n",
      "0.09 1.0 1.0\n",
      "0.091 1.0 1.0\n",
      "0.092 1.0 1.0\n",
      "0.093 1.0 1.0\n",
      "0.094 1.0 1.0\n",
      "0.095 1.0 1.0\n",
      "0.096 1.0 1.0\n",
      "0.097 1.0 1.0\n",
      "0.098 1.0 1.0\n",
      "0.099 1.0 1.0\n",
      "0.1 1.0 1.0\n",
      "0.101 1.0 1.0\n",
      "0.102 1.0 1.0\n",
      "0.103 1.0 1.0\n",
      "0.104 1.0 1.0\n",
      "0.105 1.0 1.0\n",
      "0.106 1.0 1.0\n",
      "0.107 1.0 1.0\n",
      "0.108 1.0 1.0\n",
      "0.109 1.0 1.0\n",
      "0.11 1.0 1.0\n",
      "0.111 1.0 1.0\n",
      "0.112 1.0 1.0\n",
      "0.113 1.0 1.0\n",
      "0.114 1.0 1.0\n",
      "0.115 1.0 1.0\n",
      "0.116 1.0 1.0\n",
      "0.117 1.0 1.0\n",
      "0.118 1.0 1.0\n",
      "0.119 1.0 1.0\n",
      "0.12 1.0 1.0\n",
      "0.121 1.0 1.0\n",
      "0.122 1.0 1.0\n",
      "0.123 1.0 1.0\n",
      "0.124 1.0 1.0\n",
      "0.125 1.0 1.0\n",
      "0.126 1.0 1.0\n",
      "0.127 1.0 1.0\n",
      "0.128 1.0 1.0\n",
      "0.129 1.0 1.0\n",
      "0.13 1.0 1.0\n",
      "0.131 1.0 1.0\n",
      "0.132 1.0 1.0\n",
      "0.133 1.0 1.0\n",
      "0.134 1.0 1.0\n",
      "0.135 1.0 1.0\n",
      "0.136 1.0 1.0\n",
      "0.137 1.0 1.0\n",
      "0.138 1.0 1.0\n",
      "0.139 1.0 1.0\n",
      "0.14 1.0 1.0\n",
      "0.141 1.0 1.0\n",
      "0.142 1.0 1.0\n",
      "0.143 1.0 1.0\n",
      "0.144 1.0 1.0\n",
      "0.145 1.0 1.0\n",
      "0.146 1.0 1.0\n",
      "0.147 1.0 1.0\n",
      "0.148 1.0 1.0\n",
      "0.149 1.0 1.0\n",
      "0.15 1.0 1.0\n",
      "0.151 1.0 1.0\n",
      "0.152 1.0 1.0\n",
      "0.153 1.0 1.0\n",
      "0.154 1.0 1.0\n",
      "0.155 1.0 1.0\n",
      "0.156 1.0 1.0\n",
      "0.157 1.0 1.0\n",
      "0.158 1.0 1.0\n",
      "0.159 1.0 1.0\n",
      "0.16 1.0 1.0\n",
      "0.161 1.0 1.0\n",
      "0.162 1.0 1.0\n",
      "0.163 1.0 1.0\n",
      "0.164 1.0 1.0\n",
      "0.165 1.0 1.0\n",
      "0.166 1.0 1.0\n",
      "0.167 1.0 1.0\n",
      "0.168 1.0 1.0\n",
      "0.169 1.0 1.0\n",
      "0.17 1.0 1.0\n",
      "0.171 1.0 1.0\n",
      "0.172 1.0 1.0\n",
      "0.173 1.0 1.0\n",
      "0.174 1.0 1.0\n",
      "0.175 1.0 1.0\n",
      "0.176 1.0 1.0\n",
      "0.177 1.0 1.0\n",
      "0.178 1.0 1.0\n",
      "0.179 1.0 1.0\n",
      "0.18 1.0 1.0\n",
      "0.181 1.0 1.0\n",
      "0.182 1.0 1.0\n",
      "0.183 1.0 1.0\n",
      "0.184 1.0 1.0\n",
      "0.185 1.0 1.0\n",
      "0.186 1.0 1.0\n",
      "0.187 1.0 1.0\n",
      "0.188 1.0 1.0\n",
      "0.189 1.0 1.0\n",
      "0.19 1.0 1.0\n",
      "0.191 1.0 1.0\n",
      "0.192 1.0 1.0\n",
      "0.193 1.0 1.0\n",
      "0.194 1.0 1.0\n",
      "0.195 1.0 1.0\n",
      "0.196 1.0 1.0\n",
      "0.197 1.0 1.0\n",
      "0.198 1.0 1.0\n",
      "0.199 1.0 1.0\n",
      "0.2 1.0 1.0\n",
      "0.201 1.0 1.0\n",
      "0.202 1.0 1.0\n",
      "0.203 1.0 1.0\n",
      "0.204 1.0 1.0\n",
      "0.205 1.0 1.0\n",
      "0.206 1.0 1.0\n",
      "0.207 1.0 1.0\n",
      "0.208 1.0 1.0\n",
      "0.209 1.0 1.0\n",
      "0.21 1.0 1.0\n",
      "0.211 1.0 1.0\n",
      "0.212 1.0 1.0\n",
      "0.213 1.0 1.0\n",
      "0.214 1.0 1.0\n",
      "0.215 1.0 1.0\n",
      "0.216 1.0 1.0\n",
      "0.217 1.0 1.0\n",
      "0.218 1.0 1.0\n",
      "0.219 1.0 1.0\n",
      "0.22 1.0 1.0\n",
      "0.221 1.0 1.0\n",
      "0.222 1.0 1.0\n",
      "0.223 1.0 1.0\n",
      "0.224 1.0 1.0\n",
      "0.225 1.0 1.0\n",
      "0.226 1.0 1.0\n",
      "0.227 1.0 1.0\n",
      "0.228 1.0 1.0\n",
      "0.229 1.0 1.0\n",
      "0.23 1.0 1.0\n",
      "0.231 1.0 1.0\n",
      "0.232 1.0 1.0\n",
      "0.233 1.0 1.0\n",
      "0.234 1.0 1.0\n",
      "0.235 1.0 1.0\n",
      "0.236 1.0 1.0\n",
      "0.237 1.0 1.0\n",
      "0.238 1.0 1.0\n",
      "0.239 1.0 1.0\n",
      "0.24 1.0 1.0\n",
      "0.241 1.0 1.0\n",
      "0.242 1.0 1.0\n",
      "0.243 1.0 1.0\n",
      "0.244 1.0 1.0\n",
      "0.245 1.0 1.0\n",
      "0.246 1.0 1.0\n",
      "0.247 1.0 1.0\n",
      "0.248 1.0 1.0\n",
      "0.249 1.0 1.0\n",
      "0.25 1.0 1.0\n",
      "0.251 1.0 1.0\n",
      "0.252 1.0 1.0\n",
      "0.253 1.0 1.0\n",
      "0.254 1.0 1.0\n",
      "0.255 1.0 1.0\n",
      "0.256 1.0 1.0\n",
      "0.257 1.0 1.0\n",
      "0.258 1.0 1.0\n",
      "0.259 1.0 1.0\n",
      "0.26 1.0 1.0\n",
      "0.261 1.0 1.0\n",
      "0.262 1.0 1.0\n",
      "0.263 1.0 1.0\n",
      "0.264 1.0 1.0\n",
      "0.265 1.0 1.0\n",
      "0.266 1.0 1.0\n",
      "0.267 1.0 1.0\n",
      "0.268 1.0 1.0\n",
      "0.269 1.0 1.0\n",
      "0.27 1.0 1.0\n",
      "0.271 1.0 1.0\n",
      "0.272 1.0 1.0\n",
      "0.273 1.0 1.0\n",
      "0.274 1.0 1.0\n",
      "0.275 1.0 1.0\n",
      "0.276 1.0 1.0\n",
      "0.277 1.0 1.0\n",
      "0.278 1.0 1.0\n",
      "0.279 1.0 1.0\n",
      "0.28 1.0 1.0\n",
      "0.281 1.0 1.0\n",
      "0.282 1.0 1.0\n",
      "0.283 1.0 1.0\n",
      "0.284 1.0 1.0\n",
      "0.285 1.0 1.0\n",
      "0.286 1.0 1.0\n",
      "0.287 1.0 1.0\n",
      "0.288 1.0 1.0\n",
      "0.289 1.0 1.0\n",
      "0.29 1.0 1.0\n",
      "0.291 1.0 1.0\n",
      "0.292 1.0 1.0\n",
      "0.293 1.0 1.0\n",
      "0.294 1.0 1.0\n",
      "0.295 1.0 1.0\n",
      "0.296 1.0 1.0\n",
      "0.297 1.0 1.0\n",
      "0.298 1.0 1.0\n",
      "0.299 1.0 1.0\n",
      "0.3 1.0 1.0\n",
      "0.301 1.0 1.0\n",
      "0.302 1.0 1.0\n",
      "0.303 1.0 1.0\n",
      "0.304 1.0 1.0\n",
      "0.305 1.0 1.0\n",
      "0.306 1.0 1.0\n",
      "0.307 1.0 1.0\n",
      "0.308 1.0 1.0\n",
      "0.309 1.0 1.0\n",
      "0.31 1.0 1.0\n",
      "0.311 1.0 1.0\n",
      "0.312 1.0 1.0\n",
      "0.313 1.0 1.0\n",
      "0.314 1.0 1.0\n",
      "0.315 1.0 1.0\n",
      "0.316 1.0 1.0\n",
      "0.317 1.0 1.0\n",
      "0.318 1.0 1.0\n",
      "0.319 1.0 1.0\n",
      "0.32 1.0 1.0\n",
      "0.321 1.0 1.0\n",
      "0.322 1.0 1.0\n",
      "0.323 1.0 1.0\n",
      "0.324 1.0 1.0\n",
      "0.325 1.0 1.0\n",
      "0.326 1.0 1.0\n",
      "0.327 1.0 1.0\n",
      "0.328 1.0 1.0\n",
      "0.329 1.0 1.0\n",
      "0.33 1.0 1.0\n",
      "0.331 1.0 1.0\n",
      "0.332 1.0 1.0\n",
      "0.333 1.0 1.0\n",
      "0.334 1.0 1.0\n",
      "0.335 1.0 1.0\n",
      "0.336 1.0 1.0\n",
      "0.337 1.0 1.0\n",
      "0.338 1.0 1.0\n",
      "0.339 1.0 1.0\n",
      "0.34 1.0 1.0\n",
      "0.341 1.0 1.0\n",
      "0.342 1.0 1.0\n",
      "0.343 1.0 1.0\n",
      "0.344 1.0 1.0\n",
      "0.345 1.0 1.0\n",
      "0.346 1.0 1.0\n",
      "0.347 1.0 1.0\n",
      "0.348 1.0 1.0\n",
      "0.349 1.0 1.0\n",
      "0.35 1.0 1.0\n",
      "0.351 1.0 1.0\n",
      "0.352 1.0 1.0\n",
      "0.353 1.0 1.0\n",
      "0.354 1.0 1.0\n",
      "0.355 1.0 1.0\n",
      "0.356 1.0 1.0\n",
      "0.357 1.0 1.0\n",
      "0.358 1.0 1.0\n",
      "0.359 1.0 1.0\n",
      "0.36 1.0 1.0\n",
      "0.361 1.0 1.0\n",
      "0.362 1.0 1.0\n",
      "0.363 1.0 1.0\n",
      "0.364 1.0 1.0\n",
      "0.365 1.0 1.0\n",
      "0.366 1.0 1.0\n",
      "0.367 1.0 1.0\n",
      "0.368 1.0 1.0\n",
      "0.369 1.0 1.0\n",
      "0.37 1.0 1.0\n",
      "0.371 1.0 1.0\n",
      "0.372 1.0 1.0\n",
      "0.373 1.0 1.0\n",
      "0.374 1.0 1.0\n",
      "0.375 1.0 1.0\n",
      "0.376 1.0 1.0\n",
      "0.377 1.0 1.0\n",
      "0.378 1.0 1.0\n",
      "0.379 1.0 1.0\n",
      "0.38 1.0 1.0\n",
      "0.381 1.0 1.0\n",
      "0.382 1.0 1.0\n",
      "0.383 1.0 1.0\n",
      "0.384 1.0 1.0\n",
      "0.385 1.0 1.0\n",
      "0.386 1.0 1.0\n",
      "0.387 1.0 1.0\n",
      "0.388 1.0 1.0\n",
      "0.389 1.0 1.0\n",
      "0.39 1.0 1.0\n",
      "0.391 1.0 1.0\n",
      "0.392 1.0 1.0\n",
      "0.393 1.0 1.0\n",
      "0.394 1.0 1.0\n",
      "0.395 1.0 1.0\n",
      "0.396 1.0 1.0\n",
      "0.397 1.0 1.0\n",
      "0.398 1.0 1.0\n",
      "0.399 1.0 1.0\n",
      "0.4 1.0 1.0\n",
      "0.401 1.0 1.0\n",
      "0.402 1.0 1.0\n",
      "0.403 1.0 1.0\n",
      "0.404 1.0 1.0\n",
      "0.405 1.0 1.0\n",
      "0.406 1.0 1.0\n",
      "0.407 1.0 1.0\n",
      "0.408 1.0 1.0\n",
      "0.409 1.0 1.0\n",
      "0.41 1.0 1.0\n",
      "0.411 1.0 1.0\n",
      "0.412 1.0 1.0\n",
      "0.413 1.0 1.0\n",
      "0.414 1.0 1.0\n",
      "0.415 1.0 1.0\n",
      "0.416 1.0 1.0\n",
      "0.417 1.0 1.0\n",
      "0.418 1.0 1.0\n",
      "0.419 1.0 1.0\n",
      "0.42 1.0 1.0\n",
      "0.421 1.0 1.0\n",
      "0.422 1.0 1.0\n",
      "0.423 1.0 1.0\n",
      "0.424 1.0 1.0\n",
      "0.425 1.0 1.0\n",
      "0.426 1.0 1.0\n",
      "0.427 1.0 1.0\n",
      "0.428 1.0 1.0\n",
      "0.429 1.0 1.0\n",
      "0.43 1.0 1.0\n",
      "0.431 1.0 1.0\n",
      "0.432 1.0 1.0\n",
      "0.433 1.0 1.0\n",
      "0.434 1.0 1.0\n",
      "0.435 1.0 1.0\n",
      "0.436 1.0 1.0\n",
      "0.437 1.0 1.0\n",
      "0.438 1.0 1.0\n",
      "0.439 1.0 1.0\n",
      "0.44 1.0 1.0\n",
      "0.441 1.0 1.0\n",
      "0.442 1.0 1.0\n",
      "0.443 1.0 1.0\n",
      "0.444 1.0 1.0\n",
      "0.445 1.0 1.0\n",
      "0.446 1.0 1.0\n",
      "0.447 1.0 1.0\n",
      "0.448 1.0 1.0\n",
      "0.449 1.0 1.0\n",
      "0.45 1.0 1.0\n",
      "0.451 1.0 1.0\n",
      "0.452 1.0 1.0\n",
      "0.453 1.0 1.0\n",
      "0.454 1.0 1.0\n",
      "0.455 1.0 1.0\n",
      "0.456 1.0 1.0\n",
      "0.457 1.0 1.0\n",
      "0.458 1.0 1.0\n",
      "0.459 1.0 1.0\n",
      "0.46 1.0 1.0\n",
      "0.461 1.0 1.0\n",
      "0.462 1.0 1.0\n",
      "0.463 1.0 1.0\n",
      "0.464 1.0 1.0\n",
      "0.465 1.0 1.0\n",
      "0.466 1.0 1.0\n",
      "0.467 1.0 1.0\n",
      "0.468 1.0 1.0\n",
      "0.469 1.0 1.0\n",
      "0.47 1.0 1.0\n",
      "0.471 1.0 1.0\n",
      "0.472 1.0 1.0\n",
      "0.473 1.0 1.0\n",
      "0.474 1.0 1.0\n",
      "0.475 1.0 1.0\n",
      "0.476 1.0 1.0\n",
      "0.477 1.0 1.0\n",
      "0.478 1.0 1.0\n",
      "0.479 1.0 1.0\n",
      "0.48 1.0 1.0\n",
      "0.481 1.0 1.0\n",
      "0.482 1.0 1.0\n",
      "0.483 1.0 1.0\n",
      "0.484 1.0 1.0\n",
      "0.485 1.0 1.0\n",
      "0.486 1.0 1.0\n",
      "0.487 1.0 1.0\n",
      "0.488 1.0 1.0\n",
      "0.489 1.0 1.0\n",
      "0.49 1.0 1.0\n",
      "0.491 1.0 1.0\n",
      "0.492 1.0 1.0\n",
      "0.493 1.0 1.0\n",
      "0.494 1.0 1.0\n",
      "0.495 1.0 1.0\n",
      "0.496 1.0 1.0\n",
      "0.497 1.0 1.0\n",
      "0.498 1.0 1.0\n",
      "0.499 1.0 1.0\n",
      "0.5 1.0 1.0\n",
      "0.501 1.0 1.0\n",
      "0.502 1.0 1.0\n",
      "0.503 1.0 1.0\n",
      "0.504 1.0 1.0\n",
      "0.505 1.0 1.0\n",
      "0.506 1.0 1.0\n",
      "0.507 1.0 1.0\n",
      "0.508 1.0 1.0\n",
      "0.509 1.0 1.0\n",
      "0.51 1.0 1.0\n",
      "0.511 1.0 1.0\n",
      "0.512 1.0 1.0\n",
      "0.513 1.0 1.0\n",
      "0.514 1.0 1.0\n",
      "0.515 1.0 1.0\n",
      "0.516 1.0 1.0\n",
      "0.517 1.0 1.0\n",
      "0.518 1.0 1.0\n",
      "0.519 1.0 1.0\n",
      "0.52 1.0 1.0\n",
      "0.521 1.0 1.0\n",
      "0.522 1.0 1.0\n",
      "0.523 1.0 1.0\n",
      "0.524 1.0 1.0\n",
      "0.525 1.0 1.0\n",
      "0.526 1.0 1.0\n",
      "0.527 1.0 1.0\n",
      "0.528 1.0 1.0\n",
      "0.529 1.0 1.0\n",
      "0.53 1.0 1.0\n",
      "0.531 1.0 1.0\n",
      "0.532 1.0 1.0\n",
      "0.533 1.0 1.0\n",
      "0.534 1.0 1.0\n",
      "0.535 1.0 1.0\n",
      "0.536 1.0 1.0\n",
      "0.537 1.0 1.0\n",
      "0.538 1.0 1.0\n",
      "0.539 1.0 1.0\n",
      "0.54 1.0 1.0\n",
      "0.541 1.0 1.0\n",
      "0.542 1.0 1.0\n",
      "0.543 1.0 1.0\n",
      "0.544 1.0 1.0\n",
      "0.545 1.0 1.0\n",
      "0.546 1.0 1.0\n",
      "0.547 1.0 1.0\n",
      "0.548 1.0 1.0\n",
      "0.549 1.0 1.0\n",
      "0.55 1.0 1.0\n",
      "0.551 1.0 1.0\n",
      "0.552 1.0 1.0\n",
      "0.553 1.0 1.0\n",
      "0.554 1.0 1.0\n",
      "0.555 1.0 1.0\n",
      "0.556 1.0 1.0\n",
      "0.557 1.0 1.0\n",
      "0.558 1.0 1.0\n",
      "0.559 1.0 1.0\n",
      "0.56 1.0 1.0\n",
      "0.561 1.0 1.0\n",
      "0.562 1.0 1.0\n",
      "0.563 1.0 1.0\n",
      "0.564 1.0 1.0\n",
      "0.565 1.0 1.0\n",
      "0.566 1.0 1.0\n",
      "0.567 1.0 1.0\n",
      "0.568 1.0 1.0\n",
      "0.569 1.0 1.0\n",
      "0.57 1.0 1.0\n",
      "0.571 1.0 1.0\n",
      "0.572 1.0 1.0\n",
      "0.573 1.0 1.0\n",
      "0.574 1.0 1.0\n",
      "0.575 1.0 1.0\n",
      "0.576 1.0 1.0\n",
      "0.577 1.0 1.0\n",
      "0.578 1.0 1.0\n",
      "0.579 1.0 1.0\n",
      "0.58 1.0 1.0\n",
      "0.581 1.0 1.0\n",
      "0.582 1.0 1.0\n",
      "0.583 1.0 1.0\n",
      "0.584 1.0 1.0\n",
      "0.585 1.0 1.0\n",
      "0.586 1.0 1.0\n",
      "0.587 1.0 1.0\n",
      "0.588 1.0 1.0\n",
      "0.589 1.0 1.0\n",
      "0.59 1.0 1.0\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.591 1.0 1.0\n",
      "0.592 1.0 1.0\n",
      "0.593 1.0 1.0\n",
      "0.594 1.0 1.0\n",
      "0.595 1.0 1.0\n",
      "0.596 1.0 1.0\n",
      "0.597 1.0 1.0\n",
      "0.598 1.0 1.0\n",
      "0.599 1.0 1.0\n",
      "0.6 1.0 1.0\n",
      "0.601 1.0 1.0\n",
      "0.602 1.0 1.0\n",
      "0.603 1.0 1.0\n",
      "0.604 1.0 1.0\n",
      "0.605 1.0 1.0\n",
      "0.606 1.0 1.0\n",
      "0.607 1.0 1.0\n",
      "0.608 1.0 1.0\n",
      "0.609 1.0 1.0\n",
      "0.61 1.0 1.0\n",
      "0.611 1.0 1.0\n",
      "0.612 1.0 1.0\n",
      "0.613 1.0 1.0\n",
      "0.614 1.0 1.0\n",
      "0.615 1.0 1.0\n",
      "0.616 1.0 1.0\n",
      "0.617 1.0 1.0\n",
      "0.618 1.0 1.0\n",
      "0.619 1.0 1.0\n",
      "0.62 1.0 1.0\n",
      "0.621 1.0 1.0\n",
      "0.622 1.0 1.0\n",
      "0.623 1.0 1.0\n",
      "0.624 1.0 1.0\n",
      "0.625 1.0 1.0\n",
      "0.626 1.0 1.0\n",
      "0.627 1.0 1.0\n",
      "0.628 1.0 1.0\n",
      "0.629 1.0 1.0\n",
      "0.63 1.0 1.0\n",
      "0.631 1.0 1.0\n",
      "0.632 1.0 1.0\n",
      "0.633 1.0 1.0\n",
      "0.634 1.0 1.0\n",
      "0.635 1.0 1.0\n",
      "0.636 1.0 1.0\n",
      "0.637 1.0 1.0\n",
      "0.638 1.0 1.0\n",
      "0.639 1.0 1.0\n",
      "0.64 1.0 1.0\n",
      "0.641 1.0 1.0\n",
      "0.642 1.0 1.0\n",
      "0.643 1.0 1.0\n",
      "0.644 1.0 1.0\n",
      "0.645 1.0 1.0\n",
      "0.646 1.0 1.0\n",
      "0.647 1.0 1.0\n",
      "0.648 1.0 1.0\n",
      "0.649 1.0 1.0\n",
      "0.65 1.0 1.0\n",
      "0.651 1.0 1.0\n",
      "0.652 1.0 1.0\n",
      "0.653 1.0 1.0\n",
      "0.654 1.0 1.0\n",
      "0.655 1.0 1.0\n",
      "0.656 1.0 1.0\n",
      "0.657 1.0 1.0\n",
      "0.658 1.0 1.0\n",
      "0.659 1.0 1.0\n",
      "0.66 1.0 1.0\n",
      "0.661 1.0 1.0\n",
      "0.662 1.0 1.0\n",
      "0.663 1.0 1.0\n",
      "0.664 1.0 1.0\n",
      "0.665 1.0 1.0\n",
      "0.666 1.0 1.0\n",
      "0.667 1.0 1.0\n",
      "0.668 1.0 1.0\n",
      "0.669 1.0 1.0\n",
      "0.67 1.0 1.0\n",
      "0.671 1.0 1.0\n",
      "0.672 1.0 1.0\n",
      "0.673 1.0 1.0\n",
      "0.674 1.0 1.0\n",
      "0.675 1.0 1.0\n",
      "0.676 1.0 1.0\n",
      "0.677 1.0 1.0\n",
      "0.678 1.0 1.0\n",
      "0.679 1.0 1.0\n",
      "0.68 1.0 1.0\n",
      "0.681 1.0 1.0\n",
      "0.682 1.0 1.0\n",
      "0.683 1.0 1.0\n",
      "0.684 1.0 1.0\n",
      "0.685 1.0 1.0\n",
      "0.686 1.0 1.0\n",
      "0.687 1.0 1.0\n",
      "0.688 1.0 1.0\n",
      "0.689 1.0 1.0\n",
      "0.69 1.0 1.0\n",
      "0.691 1.0 1.0\n",
      "0.692 1.0 1.0\n",
      "0.693 1.0 1.0\n",
      "0.694 1.0 1.0\n",
      "0.695 1.0 1.0\n",
      "0.696 1.0 1.0\n",
      "0.697 1.0 1.0\n",
      "0.698 1.0 1.0\n",
      "0.699 1.0 1.0\n",
      "0.7 1.0 1.0\n",
      "0.701 1.0 1.0\n",
      "0.702 1.0 1.0\n",
      "0.703 1.0 1.0\n",
      "0.704 1.0 1.0\n",
      "0.705 1.0 1.0\n",
      "0.706 1.0 1.0\n",
      "0.707 1.0 1.0\n",
      "0.708 1.0 1.0\n",
      "0.709 1.0 1.0\n",
      "0.71 1.0 1.0\n",
      "0.711 1.0 1.0\n",
      "0.712 1.0 1.0\n",
      "0.713 1.0 1.0\n",
      "0.714 1.0 1.0\n",
      "0.715 1.0 1.0\n",
      "0.716 1.0 1.0\n",
      "0.717 1.0 1.0\n",
      "0.718 1.0 1.0\n",
      "0.719 1.0 1.0\n",
      "0.72 1.0 1.0\n",
      "0.721 1.0 1.0\n",
      "0.722 1.0 1.0\n",
      "0.723 1.0 1.0\n",
      "0.724 1.0 1.0\n",
      "0.725 1.0 1.0\n",
      "0.726 1.0 1.0\n",
      "0.727 1.0 1.0\n",
      "0.728 1.0 1.0\n",
      "0.729 1.0 1.0\n",
      "0.73 1.0 1.0\n",
      "0.731 1.0 1.0\n",
      "0.732 1.0 1.0\n",
      "0.733 1.0 1.0\n",
      "0.734 1.0 1.0\n",
      "0.735 1.0 1.0\n",
      "0.736 1.0 1.0\n",
      "0.737 1.0 1.0\n",
      "0.738 1.0 1.0\n",
      "0.739 1.0 1.0\n",
      "0.74 1.0 1.0\n",
      "0.741 1.0 1.0\n",
      "0.742 1.0 1.0\n",
      "0.743 1.0 1.0\n",
      "0.744 1.0 1.0\n",
      "0.745 1.0 1.0\n",
      "0.746 1.0 1.0\n",
      "0.747 1.0 1.0\n",
      "0.748 1.0 1.0\n",
      "0.749 1.0 1.0\n",
      "0.75 1.0 1.0\n",
      "0.751 1.0 1.0\n",
      "0.752 1.0 1.0\n",
      "0.753 1.0 1.0\n",
      "0.754 1.0 1.0\n",
      "0.755 1.0 1.0\n",
      "0.756 1.0 1.0\n",
      "0.757 1.0 1.0\n",
      "0.758 1.0 1.0\n",
      "0.759 1.0 1.0\n",
      "0.76 1.0 1.0\n",
      "0.761 1.0 1.0\n",
      "0.762 1.0 1.0\n",
      "0.763 1.0 1.0\n",
      "0.764 1.0 1.0\n",
      "0.765 1.0 1.0\n",
      "0.766 1.0 1.0\n",
      "0.767 1.0 1.0\n",
      "0.768 1.0 1.0\n",
      "0.769 1.0 1.0\n",
      "0.77 1.0 1.0\n",
      "0.771 1.0 1.0\n",
      "0.772 1.0 1.0\n",
      "0.773 1.0 1.0\n",
      "0.774 1.0 1.0\n",
      "0.775 1.0 1.0\n",
      "0.776 1.0 1.0\n",
      "0.777 1.0 1.0\n",
      "0.778 1.0 1.0\n",
      "0.779 1.0 1.0\n",
      "0.78 1.0 1.0\n",
      "0.781 1.0 1.0\n",
      "0.782 1.0 1.0\n",
      "0.783 1.0 1.0\n",
      "0.784 1.0 1.0\n",
      "0.785 1.0 1.0\n",
      "0.786 1.0 1.0\n",
      "0.787 1.0 1.0\n",
      "0.788 1.0 1.0\n",
      "0.789 1.0 1.0\n",
      "0.79 1.0 1.0\n",
      "0.791 1.0 1.0\n",
      "0.792 1.0 1.0\n",
      "0.793 1.0 1.0\n",
      "0.794 1.0 1.0\n",
      "0.795 1.0 1.0\n",
      "0.796 1.0 1.0\n",
      "0.797 1.0 1.0\n",
      "0.798 1.0 1.0\n",
      "0.799 1.0 1.0\n",
      "0.8 1.0 1.0\n",
      "0.801 1.0 1.0\n",
      "0.802 1.0 1.0\n",
      "0.803 1.0 1.0\n",
      "0.804 1.0 1.0\n",
      "0.805 1.0 1.0\n",
      "0.806 1.0 1.0\n",
      "0.807 1.0 1.0\n",
      "0.808 1.0 1.0\n",
      "0.809 1.0 1.0\n",
      "0.81 1.0 1.0\n",
      "0.811 1.0 1.0\n",
      "0.812 1.0 1.0\n",
      "0.813 1.0 1.0\n",
      "0.814 1.0 1.0\n",
      "0.815 1.0 1.0\n",
      "0.816 1.0 1.0\n",
      "0.817 1.0 1.0\n",
      "0.818 1.0 1.0\n",
      "0.819 1.0 1.0\n",
      "0.82 1.0 1.0\n",
      "0.821 1.0 1.0\n",
      "0.822 1.0 1.0\n",
      "0.823 1.0 1.0\n",
      "0.824 1.0 1.0\n",
      "0.825 1.0 1.0\n",
      "0.826 1.0 1.0\n",
      "0.827 1.0 1.0\n",
      "0.828 1.0 1.0\n",
      "0.829 1.0 1.0\n",
      "0.83 1.0 1.0\n",
      "0.831 1.0 1.0\n",
      "0.832 1.0 1.0\n",
      "0.833 1.0 1.0\n",
      "0.834 1.0 1.0\n",
      "0.835 1.0 1.0\n",
      "0.836 1.0 1.0\n",
      "0.837 1.0 1.0\n",
      "0.838 1.0 1.0\n",
      "0.839 1.0 1.0\n",
      "0.84 1.0 1.0\n",
      "0.841 1.0 1.0\n",
      "0.842 1.0 1.0\n",
      "0.843 1.0 1.0\n",
      "0.844 1.0 1.0\n",
      "0.845 1.0 1.0\n",
      "0.846 1.0 1.0\n",
      "0.847 1.0 1.0\n",
      "0.848 1.0 1.0\n",
      "0.849 1.0 1.0\n",
      "0.85 1.0 1.0\n",
      "0.851 1.0 1.0\n",
      "0.852 1.0 1.0\n",
      "0.853 1.0 1.0\n",
      "0.854 1.0 1.0\n",
      "0.855 1.0 1.0\n",
      "0.856 1.0 1.0\n",
      "0.857 1.0 1.0\n",
      "0.858 1.0 1.0\n",
      "0.859 1.0 1.0\n",
      "0.86 1.0 1.0\n",
      "0.861 1.0 1.0\n",
      "0.862 1.0 1.0\n",
      "0.863 1.0 1.0\n",
      "0.864 1.0 1.0\n",
      "0.865 1.0 1.0\n",
      "0.866 1.0 1.0\n",
      "0.867 1.0 1.0\n",
      "0.868 1.0 1.0\n",
      "0.869 1.0 1.0\n",
      "0.87 1.0 1.0\n",
      "0.871 1.0 1.0\n",
      "0.872 1.0 1.0\n",
      "0.873 1.0 1.0\n",
      "0.874 1.0 1.0\n",
      "0.875 1.0 1.0\n",
      "0.876 1.0 1.0\n",
      "0.877 1.0 1.0\n",
      "0.878 1.0 1.0\n",
      "0.879 1.0 1.0\n",
      "0.88 1.0 1.0\n",
      "0.881 1.0 1.0\n",
      "0.882 1.0 1.0\n",
      "0.883 1.0 1.0\n",
      "0.884 1.0 1.0\n",
      "0.885 1.0 1.0\n",
      "0.886 1.0 1.0\n",
      "0.887 1.0 1.0\n",
      "0.888 1.0 1.0\n",
      "0.889 1.0 1.0\n",
      "0.89 1.0 1.0\n",
      "0.891 1.0 1.0\n",
      "0.892 1.0 1.0\n",
      "0.893 1.0 1.0\n",
      "0.894 1.0 1.0\n",
      "0.895 1.0 1.0\n",
      "0.896 1.0 1.0\n",
      "0.897 1.0 1.0\n",
      "0.898 1.0 1.0\n",
      "0.899 1.0 1.0\n",
      "0.9 1.0 1.0\n",
      "0.901 1.0 1.0\n",
      "0.902 1.0 1.0\n",
      "0.903 1.0 1.0\n",
      "0.904 1.0 1.0\n",
      "0.905 1.0 1.0\n",
      "0.906 1.0 1.0\n",
      "0.907 1.0 1.0\n",
      "0.908 1.0 1.0\n",
      "0.909 1.0 1.0\n",
      "0.91 1.0 1.0\n",
      "0.911 1.0 1.0\n",
      "0.912 1.0 1.0\n",
      "0.913 1.0 1.0\n",
      "0.914 1.0 1.0\n",
      "0.915 0.9999999999352382 1.0\n",
      "0.916 0.9754683074728827 1.0\n",
      "0.917 3.9105084705510655e-08 1.0\n",
      "0.918 2.011201789912105e-17 1.0\n",
      "0.919 5.35317859857691e-27 1.0\n",
      "0.92 7.298276623098329e-37 1.0\n",
      "0.921 5.045091714136283e-47 1.0\n",
      "0.922 1.7507490018026848e-57 1.0\n",
      "0.923 3.0202221376329294e-68 1.0\n",
      "0.924 2.5654691409023634e-79 1.0\n",
      "0.925 1.0630898495240192e-90 1.0\n",
      "0.926 2.1297663756049827e-102 1.0\n",
      "0.927 2.0448887216711595e-114 1.0\n",
      "0.928 9.331385635677315e-127 1.0\n",
      "0.929 2.007631074060292e-139 1.0\n",
      "0.93 2.0210599180656664e-152 1.0\n",
      "0.931 9.45184475217713e-166 1.0\n",
      "0.932 2.039785914193044e-179 1.0\n",
      "0.933 2.0187934178134433e-193 1.0\n",
      "0.934 9.111383070581456e-208 1.0\n",
      "0.935 1.8657899311660292e-222 1.0\n",
      "0.936 1.7258449823843646e-237 1.0\n",
      "0.937 7.184048833124253e-253 1.0\n",
      "0.938 1.3416733719121434e-268 1.0\n",
      "0.939 1.1216337652980953e-284 1.0\n",
      "0.94 4.191373237900545e-301 1.0\n",
      "0.941 6.997096e-318 1.0\n",
      "0.942 0.0 1.0\n",
      "0.943 0.0 1.0\n",
      "0.944 0.0 1.0\n",
      "0.945 0.0 1.0\n",
      "0.946 0.0 1.0\n",
      "0.947 0.0 1.0\n",
      "0.948 0.0 1.0\n",
      "0.949 0.0 1.0\n",
      "0.95 0.0 1.0\n",
      "0.951 0.0 1.0\n",
      "0.952 0.0 1.0\n",
      "0.953 0.0 1.0\n",
      "0.954 0.0 1.0\n",
      "0.955 0.0 1.0\n",
      "0.956 0.0 1.0\n",
      "0.957 0.0 1.0\n",
      "0.958 0.0 1.0\n",
      "0.959 0.0 1.0\n",
      "0.96 0.0 1.0\n",
      "0.961 0.0 1.0\n",
      "0.962 0.0 1.0\n",
      "0.963 0.0 1.0\n",
      "0.964 0.0 0.9999999999184446\n",
      "0.965 0.0 0.9222105978661115\n",
      "0.966 0.0 0.6894039233592175\n",
      "0.967 0.0 0.33173336756383803\n",
      "0.968 0.0 2.0276389673107678e-22\n",
      "0.969 0.0 1.6902950347717173e-87\n",
      "0.97 0.0 1.4090759502205666e-152\n",
      "0.971 0.0 1.1746440666562708e-217\n",
      "0.972 0.0 9.79215267356593e-283\n",
      "0.973 0.0 0.0\n",
      "0.974 0.0 0.0\n",
      "0.975 0.0 0.0\n",
      "0.976 0.0 0.0\n",
      "0.977 0.0 0.0\n",
      "0.978 0.0 0.0\n",
      "0.979 0.0 0.0\n",
      "0.98 0.0 0.0\n",
      "0.981 0.0 0.0\n",
      "0.982 0.0 0.0\n",
      "0.983 0.0 0.0\n",
      "0.984 0.0 0.0\n",
      "0.985 0.0 0.0\n",
      "0.986 0.0 0.0\n",
      "0.987 0.0 0.0\n",
      "0.988 0.0 0.0\n",
      "0.989 0.0 0.0\n",
      "0.99 0.0 0.0\n",
      "0.991 0.0 0.0\n",
      "0.992 0.0 0.0\n",
      "0.993 0.0 0.0\n",
      "0.994 0.0 0.0\n",
      "0.995 0.0 0.0\n",
      "0.996 0.0 0.0\n",
      "0.997 0.0 0.0\n",
      "0.998 0.0 0.0\n",
      "0.999 0.0 0.0\n"
     ]
    }
   ],
   "source": [
    "scale=1000\n",
    "for num in range(1,1001):\n",
    "\n",
    "    \n",
    "    if num!=1000:\n",
    "        guessl=.5\n",
    "        guessf=.5\n",
    "        FS=num/scale\n",
    "\n",
    "        mu=0\n",
    "\n",
    "        integralsF=[integral(payoffsF,z,FS) for z in range(N+1)]\n",
    "        integralsL=[integral(payoffsL,z,FS) for z in range(N+1)] \n",
    "\n",
    "        if FS>.999:\n",
    "            FS=.9995\n",
    "\n",
    "\n",
    "        for i in range(1000):\n",
    "            [guessl,guessf,payoffL,payoffF]=intermediate_period(FS,payoffsL,payoffsF,[guessl,guessf])\n",
    "            mu=mu+5\n",
    "    #         print(mu)\n",
    "        leader_probs.append(guessl)\n",
    "        follower_probs.append(guessf)\n",
    "        leader_payoffs.append(payoffL)\n",
    "        follower_payoffs.append(payoffF)\n",
    "        print(FS,guessl,guessf)\n",
    "        \n",
    "    else:\n",
    "        leader_payoffs.append(leader_payoffs[999])\n",
    "        follower_payoffs.append(follower_payoffs[999])\n",
    "        leader_probs.append(leader_probs[999])\n",
    "        follower_probs.append(follower_probs[999])\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 175,
   "metadata": {},
   "outputs": [],
   "source": [
    "with open('Alternative_Follower_Prob_Period_%s_%s_%s_%s.pkl'%(period,N,v,c), 'wb') as f:\n",
    "    pickle.dump(follower_probs,f)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 176,
   "metadata": {},
   "outputs": [],
   "source": [
    "with open('Alternative_Leader_Prob_Period_%s_%s_%s_%s.pkl'%(period,N,v,c), 'wb') as f:\n",
    "    pickle.dump(leader_probs,f)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 177,
   "metadata": {},
   "outputs": [],
   "source": [
    "with open('Alternative_Follower_Payoffs_Period_%s_%s_%s_%s.pkl'%(period,N,v,c), 'wb') as f:\n",
    "    pickle.dump(follower_payoffs,f)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 178,
   "metadata": {},
   "outputs": [],
   "source": [
    "with open('Alternative_Leader_Payoffs_Period_%s_%s_%s_%s.pkl'%(period,N,v,c), 'wb') as f:\n",
    "    pickle.dump(leader_payoffs,f)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
